<?php
namespace Admin\Controller;
use Home\Controller\BaseController;
// +----------------------------------------------------------------------
// | Date:2017年2月8日
// +----------------------------------------------------------------------
// | Author: EK_熊<1439527494@qq.com>
// +----------------------------------------------------------------------
// | Description: 此文件作用于****
// +----------------------------------------------------------------------
class SearchKeywordController extends CommentController{
    public function _initialize() {
        parent::_initialize();
        $this->model = M("SearchLog");
    }
    
    public function index(){
        $model = $this->model->group('keyword');
        $field = '*,count(*) as count';
        $list = $this->lists($this->model,$where,$order='count desc,created_time desc',$field);
        
        $this->assign('list',$list);
        $this->display();
    }
    
    public function delete(){
        $ids = I('request.ids');
        
        //通过id获取关键词名称
        $keyAry = $this->model->where(['id'=>['in',$ids]])->getField('keyword',true);
        $ret = $this->model->where(['keyword'=>['in',$keyAry]])->delete();
        if (!$ret) $this->error('操作失败,网络异常！');
        $this->success('操作成功！');
    }
    
}